package com.anti.modular.owner.ownerleasefees.controller;

import com.anti.commom.annotation.BusinessLog;
import com.anti.commom.annotation.Permission;
import com.anti.commom.enums.LogAnnotionOpTypeEnum;
import com.anti.commom.api.Result;
import com.anti.jdbc.support.page.PageParam;
import com.anti.modular.owner.ownerleasefees.param.OwnerLeaseFeesParam;
import com.anti.modular.owner.ownerleasefees.service.OwnerLeaseFeesService;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;

/**
 * 固定費用控制器
 *
 * @author anti
 * @date 2021-05-20 14:28:05
 */
@RestController
@RequestMapping("ownerLeaseFees")
public class OwnerLeaseFeesController {

    @Resource
    private OwnerLeaseFeesService ownerLeaseFeesService;

    /**
     * 查询固定費用
     *
     * @author anti
     * @date 2021-05-20 14:28:05
     */
    @GetMapping("page")
    public Result page(PageParam pageParam, OwnerLeaseFeesParam ownerLeaseFeesParam) {
        return Result.data(ownerLeaseFeesService.page(pageParam,ownerLeaseFeesParam));
    }

    /**
     * 添加固定費用
     *
     * @author anti
     * @date 2021-05-20 14:28:05
     */
    @PostMapping("add")
    @BusinessLog(title = "固定費用_增加", opType = LogAnnotionOpTypeEnum.ADD)
    public Result add(@RequestBody @Validated(OwnerLeaseFeesParam.add.class) OwnerLeaseFeesParam ownerLeaseFeesParam) {
            ownerLeaseFeesService.add(ownerLeaseFeesParam);
        return Result.success("新增成功");
    }

    /**
     * 删除固定費用
     *
     * @author anti
     * @date 2021-05-20 14:28:05
     */
    @PostMapping("delete")
    @BusinessLog(title = "固定費用_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public Result delete(@RequestBody @Validated(OwnerLeaseFeesParam.delete.class) OwnerLeaseFeesParam ownerLeaseFeesParam) {
            ownerLeaseFeesService.delete(ownerLeaseFeesParam);
        return Result.success("删除成功");
    }

    /**
     * 编辑固定費用
     *
     * @author anti
     * @date 2021-05-20 14:28:05
     */
    @PostMapping("edit")
    @BusinessLog(title = "固定費用_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    public Result edit(@RequestBody @Validated(OwnerLeaseFeesParam.edit.class) OwnerLeaseFeesParam ownerLeaseFeesParam) {
            ownerLeaseFeesService.edit(ownerLeaseFeesParam);
        return Result.success("修改成功");
    }

    /**
     * 查看固定費用
     *
     * @author anti
     * @date 2021-05-20 14:28:05
     */
    @GetMapping("detail")
    public Result detail(@Validated(OwnerLeaseFeesParam.detail.class) OwnerLeaseFeesParam ownerLeaseFeesParam) {
        return Result.data(ownerLeaseFeesService.detail(ownerLeaseFeesParam));
    }

    /**
     * 固定費用列表
     *
     * @author anti
     * @date 2021-05-20 14:28:05
     */
    @GetMapping("list")
    public Result list(OwnerLeaseFeesParam ownerLeaseFeesParam) {
        return Result.data(ownerLeaseFeesService.list(ownerLeaseFeesParam));
    }

}
